home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Ligature Splits.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.0 KB  |  89 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void LigatureSplits(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char        *myString = "fly fishing";
  39.     gxPoint        myPoint;
  40.     gxRunControls    gxRunControls;
  41.     gxShape        caret, layout;
  42.     short        i, len, level = 0;
  43.     gxStyle        myStyle;
  44.     gxViewPort    aViewPort;
  45.     
  46.     /* Initialization */
  47.     
  48.     myPoint.x = ff(20);
  49.     myPoint.y = ff(50);
  50.     
  51.     aViewPort = GXNewWindowViewPort(sampleWindow);
  52.     SetDefaultViewPort(aViewPort);
  53.     
  54.     len = MyStrLen(myString);
  55.     InitializeRunControls(&gxRunControls);
  56.  
  57.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  58.     
  59.     layout = GXNewLayout(
  60.         1, &len, (void *) &myString,
  61.         1, &len, &myStyle,
  62.         1, &len, &level,
  63.         nil, &myPoint);
  64.     GXDrawShape(layout);
  65.     
  66.     for (i = 0; i < len; i++)
  67.         {
  68.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  69.         GXDrawShape(caret);
  70.         GXDisposeShape(caret);
  71.         }
  72.     
  73.     gxRunControls.flags = gxNoLigatureSplits;
  74.     GXSetStyleRunControls(myStyle, &gxRunControls);
  75.     GXMoveShape(layout, 0, ff(75));
  76.     GXDrawShape(layout);
  77.     
  78.     for (i = 0; i < len; i++)
  79.         {
  80.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  81.         GXDrawShape(caret);
  82.         GXDisposeShape(caret);
  83.         }
  84.     
  85.     GXDisposeShape(layout);
  86.     GXDisposeStyle(myStyle);
  87.     GXDisposeViewPort(aViewPort);
  88.     }    /* main */
  89.